package kuzha.ast.validate;

import java.util.Deque;
import java.util.LinkedList;

class LabelStack {
	private final Deque<LabelInfo> labels = new LinkedList<LabelInfo>();
	public boolean hasLabel(String name) {
		for(LabelInfo li: labels) {
			if (name == null ? li.isStrong() : name.equals(li.getName())) {
				return true;
			}
		}
		return false;
	}
	public void pushLabel(String name, boolean strong) {
		labels.addFirst(new LabelInfo(name, strong));
	}
	public void popLabel() {
		labels.removeFirst();
	}
}
